package com.cloudshadow.platform.server.common.uc.protocol;


import com.cloudshadow.platform.infrastructure.exception.ErrorInfos;
import com.cloudshadow.platform.server.common.base.utils.VoUtil;
import com.cloudshadow.platform.server.common.base.vo.BasicVo;
import com.cloudshadow.platform.server.common.base.vo.TokenVo;
import com.cloudshadow.platform.server.common.uc.protocol.model.UserModel;
import com.cloudshadow.platform.server.common.uc.protocol.protocol.UcProtocol;
import com.cloudshadow.platform.server.common.uc.protocol.req.UserAddReq;
import com.cloudshadow.platform.server.common.uc.protocol.req.UserLoginReq;
import com.cloudshadow.platform.server.common.uc.protocol.req.UserSearchReq;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * Created by apple on 16/12/15.
 */
@Component
public class UserFall implements UcProtocol {

	@Override
	public BasicVo<UserModel> findAll(@RequestBody UserSearchReq searchReq) {
		return fallBack(BasicVo.class);
	}

	@Override
	public BasicVo<UserModel> findOne(@RequestParam String id) {
		return fallBack(BasicVo.class);
	}

	@Override
	public BasicVo<UserModel> save(@RequestBody UserAddReq saveReq) {
		return fallBack(BasicVo.class);
	}

	@Override
	public BasicVo<UserModel> del(@RequestParam String id) {
		return fallBack(BasicVo.class);
	}

	@Override
	public BasicVo<TokenVo> login(@RequestBody UserLoginReq req) {
		return fallBack(BasicVo.class);
	}

	protected <S extends BasicVo> S fallBack(Class<S> back) {
		return VoUtil.genErrorResult(ErrorInfos.CommonErr.SERVER_NOT_EXIST, back);
	}
}
